<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@include file="/common/common.jspf" %>
<style>
<!--
.h10{
	height: 10px;
}
-->
</style>
	<header class="panel-heading">
	<div class="doc-buttons">
		<c:forEach items="${res}" var="key">
			${key.description}
		</c:forEach>
	</div>
	</header>
	<div class="table-responsive">
		<div id="paging" class="pagclass"></div>
	</div>
	
<script type="text/javascript">

var dict = [];
<c:forEach items="${dict }" var="record">
dict.push({'value':'${record.value}','label':'${record.label}'});
</c:forEach>
var detailId='${detailId}';
var pageii = null;
var grid = null;
$(function() {
	grid = lyGrid({
		pagId : 'paging',
		l_column : [{
			colkey : "id",
			name : "兑换",
			width : "55px",
			renderData : function(rowindex,data, rowdata, column) {
				return "<img class='imgbtn' title='商品兑换' style='height:19px;width:19px;' src='" + rootPath + "/images/exchange.png' onclick=\"viewFun('"+data+"')\"/>";
			}
		},  {
			colkey : "id",
			name : "商品编号"
		}, {
			colkey : "name",
			name : "商品名称"
		}, {
			colkey : "description",
			name : "商品描述"
		},{
			colkey : "integralPrice",
			name : "所需积分"
		}
		],
		jsonUrl : rootPath + '/integral/viewCommodity.shtml?id='+detailId,
		checkbox : true
	});
});
function viewFun(cbox){
	if(confirm('确定要兑换吗？')){
  		$.ajax({
  			url : rootPath+"/integral/exchange.shtml",
  			type : "post",
  			data : {id:cbox,openid:detailId},
  			dataType : "text",
  			success : function(){
  				layer.confirm('兑换成功!是否关闭窗口?', function(index) {
  				parent.grid.loadData();
  		    	parent.layer.close(parent.pageii);
  		    	return false;
  				});
  			},
  			error:function(){
  				layer.msg("兑换失败!",3);
  			}
  		});
 	  }		
}
</script>